const path = require('path')
const webpackCommon =  require('./webpack.common')
const { merge } = require('webpack-merge')
const config = require('./webpack.cfg')

// 项目目录
const cwdDir = process.cwd()

module.exports = (env) => {
  return merge(webpackCommon('dev', env), {
    mode: 'development',
    devServer: {
      port: config.dev.port,
      // 提供静态资源路径，对于 webpack 未提供的资源，serve 会到这个路径下查找
      // 不需要在开发阶段就让 webpack 将静态资源复制
      contentBase: config.build.public,
      // 服务器获取 contentBase 配置的静态资源时的路径
      contentBasePublicPath: '/' + config.build.public,
      host: config.dev.host,
      hot: config.dev.hot,
    }
  })
}